package org.example.psn.core.controller;


import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.example.api.psn.IPersonServiceFeignClient;
import org.example.psn.core.service.IPersonService;
import org.example.system.common.bean.MyFeignBlockHandlerService;
import org.example.system.common.bean.MyFeignFallbackService;
import org.example.system.common.dto.UserAuthDto;
import org.example.system.common.dto.psn.UserInfoDto;
import org.example.system.common.utils.JwtUtils;
import org.example.system.common.utils.ResponseUtil;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 用户信息 前端控制器
 * </p>
 *
 * @author Joey
 * @since 2021-05-11
 */
@ApiSort(1)
@Api(tags = "1、用户管理")
@Slf4j
@RestController
public class PersonController implements IPersonServiceFeignClient {
    @Resource
    IPersonService personService;

    @ApiOperationSupport(order = 199)
    @ApiOperation(value = "PSN199-查询用户名称")
    @ApiImplicitParams({
            @ApiImplicitParam(name="psnIds",value="用户id集合",dataType = "string", paramType = "query",required = true)
    })
    @Override
    public ResponseUtil<String> queryNamesById(String psnIds) {
        return ResponseUtil.success(personService.queryNamesById(psnIds));
    }
    @ApiOperationSupport(order = 198)
    @ApiOperation(value = "PSN198-查询用户信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name="psnId",value="用户id",dataType = "long", paramType = "query",required = true)
    })

    @Override
    public ResponseUtil<UserInfoDto> queryPersonById(Long psnId) {
        UserInfoDto dto = personService.queryPersonById(psnId);
        return ResponseUtil.success(dto);
    }
    @ApiOperationSupport(order = 197)
    @ApiOperation(value = "PSN197-查询用户授权信息")
    @Override
    public ResponseUtil<UserAuthDto> queryAuthInfoByToken() {
        String jwt = JwtUtils.getTokenByHeader();
        UserAuthDto dto = personService.queryAuthInfoByToken(jwt);
        return ResponseUtil.success(dto);
    }
}

